package com.example.pages;

import com.example.model.Movie;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import java.io.File;

public class MovieAddPage extends MovieContentPage {

    @FindBy(id = "imbdsearh")
    public WebElement imdbSearchField;

    @FindBy(xpath = ".//*[@id='imdbsearchform']/table/tbody/tr[2]/td/input")
    public WebElement searchButton;

    public MoviePage createMovie(Movie movie){
        imdbid.sendKeys(movie.imdbid);
        name.sendKeys(movie.name);
        aka.sendKeys(movie.aka);
        year.sendKeys(movie.year);
        duration.sendKeys(movie.duration);
        rating.sendKeys(movie.rating);
        format.sendKeys(movie.format);
        if (movie.own) {
            own_yes.click();
        } else {
            own_no.click();
        }
        if (movie.seen) {
            seen_yes.click();
        } else {
            seen_no.click();
        }
        if (movie.loaned) {
            loaned_yes.click();
        } else {
            loaned_no.click();
        }
        loanname.sendKeys(movie.loanname);
        loandate.sendKeys(movie.loandate);
        cover.sendKeys(movie.cover.getAbsolutePath());
        trailer.sendKeys(movie.trailer);
        notes.sendKeys(movie.notes);
        taglines.sendKeys(movie.taglines);
        plotoutline.sendKeys(movie.plotoutline);
        plots.sendKeys(movie.plots);
        text_languages_0.sendKeys(movie.text_languages);
        subtitles.sendKeys(movie.subtitles);
        audio.sendKeys(movie.audio);
        video.sendKeys(movie.video);
        country.sendKeys(movie.country);
        genres.sendKeys(movie.genres);
        director.sendKeys(movie.director);
        writer.sendKeys(movie.writer);
        producer.sendKeys(movie.producer);
        music.sendKeys(movie.music);
        cast.sendKeys(movie.cast);
        submit.click();
        return MyPageFactory.getPage(driver,MoviePage.class);
    }
}
